home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE21
/
EX15.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-29
|
3KB
|
69 lines
#include <genstub.c>
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static char szOriginalLabel[128];
static char szRootPath[MAX_PATH + 1];
switch (uMsg)
{
case WM_CREATE:
{
// Make root path name
GetCurrentDirectory( MAX_PATH, szRootPath );
szRootPath[3] = 0;
// Store label for later restore.
GetVolumeInformation( szRootPath, szOriginalLabel,
sizeof( szOriginalLabel ) - 1,
NULL, NULL, NULL, NULL, 0 );
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
case WM_COMMAND:
switch ( LOWORD( wParam ) )
{
case IDM_TEST:
{
LPTSTR lpTemp;
char szLabel[MAX_PATH + 1];
char szCommandLine[MAX_PATH+1];
char szBuffer[2 * MAX_PATH + 32];
GetVolumeInformation( szRootPath, szLabel,
sizeof( szLabel ) - 1,
NULL, NULL, NULL, NULL, 0 );
lstrcpy( szCommandLine, GetCommandLine() );
// Search for extra input after program name.
lpTemp = strstr( szCommandLine, " " );
if (lpTemp)
lpTemp = strtok(lpTemp, " ");
if (lpTemp)
{
wsprintf( szBuffer,
"Orig Label: [%s], Current Label: [%s]",
szOriginalLabel, szLabel );
MessageBox( hWnd, szBuffer, "Changing Volume Label",
MB_OK );
SetVolumeLabel( szRootPath, lpTemp );
}
else
MessageBox( hWnd, szOriginalLabel,
"Volume Label", MB_OK );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY:
// Restore old label name.
SetVolumeLabel( szRootPath, szOriginalLabel );
PostQuitMessage( 0 );
break;
default:
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return (NULL);
}